/*
 * @Author: lll 1280388921@qq.com
 * @Date: 2025-04-13 21:59:49
 * @LastEditors: lll 1280388921@qq.com
 * @LastEditTime: 2025-04-13 21:59:50
 * @FilePath: /lesson28/comm.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once
#include<iostream>
#include<cerrno>
#include<cstring>
#include<string>
#include<unistd.h>
#include<cstdlib>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

#define FIFO_FILE "./myfifo"
#define MODE 0664

enum
{
    FIFO_CREATE_ERR=1,
    FIFO_OPEN_ERR,
    FIFO_DELETE_ERR
};

class Init
{
public:
    Init()
    {
         //创建管道
        int n=mkfifo(FIFO_FILE,MODE);
        if(n==-1)
        {
            perror("mkfifo");
            exit(FIFO_CREATE_ERR);
        }
    }
    ~Init()
    {
        //删除管道
        int m=unlink(FIFO_FILE);
        if(m==-1)
        {
            perror("unlink");
            exit(FIFO_DELETE_ERR);
        }
    }
private:

};